/*demo2*/
																   /* Nokia 6100 Color LCD routines
   Author: Martin Maly, www.uelectronics.info, author@uelectronics.info

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


  Target: Luminary Micro LM3S811
  Family: ARM7-TDMI Cortex M3
  Compiler: Keil ARM C
*/

//First demo
//demonstrates basic routines

#include "hw_ints.h"
#include "hw_memmap.h"
#include "hw_types.h"
#include "debug.h"
#include "gpio.h"
#include "interrupt.h"
#include "sysctl.h"
#include "../diag.h"
#include "../osram96x16.h"
#include "lcd.h"
#include "font.h"
#include "lcd4096.h"

#define USER_LED GPIO_PIN_5

void dly2(int a){
 long int i;
 long int j;
 j=10000*a;
 for (i=0;i<j;i++){ ; }
}


//buffer for full color animation
word buffer[32][32];

void clear(word *buffer){
 int i;
 for(i=0;i<50*50;i++) buffer[i]=0;
}

int main(void){
    // Luminary Micro LM3S811 ARM7 chip specific startup
    // Set the clocking to run directly from the crystal.

	int dly=1;
	int i,j;

    SysCtlClockSet(SYSCTL_SYSDIV_2 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
				   SYSCTL_INT_OSC_DIS |	
                   SYSCTL_XTAL_6MHZ);

	//Set peripherials for some demo stuff (LED blinking)
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
	GPIODirModeSet(GPIO_PORTC_BASE, USER_LED, GPIO_DIR_MODE_OUT);

	//LCD startup
	LCD_init(); 


//Switch to 8bit-per-pixel mode
LCD_8bpp();
//prepare default 3-3-2 palette
//it means every byte has the "rrrg ggbb" format (3 bits
//for red, 3 bits for green and 2 bits for blue)
LCD_palette();

//Drawing the same color rectangles as above to show the lesser
//color depth


//Draw the cross - just demo of general LINE function
LCD_line(0,0,130,130,LCD_color(0,0,14));
LCD_line(0,130,130,0,LCD_color(0,14,14));
//demo of CIRCLE functions
LCD_circle(66,66,50,LCD_color(15,0,15));
LCD_circle_fill(66,66,20,LCD_color(15,15,0));

for (i=1;i<16;i++) {
  LCD_circle_fill(8*i,6,5,LCD_color(0,i,i));
  LCD_circle_fill(8*i,15,5,LCD_color(16-i,0,16-i));
}

for (i=0;i<16;i++) {
	LCD_hline(0,19,i+99,LCD_color(0,0,i));
	LCD_hline(20,39,i+99,LCD_color(0,i,0));
	LCD_hline(40,59,i+99,LCD_color(i,0,0));
	LCD_hline(60,79,i+99,LCD_color(0,i,i));
	LCD_hline(80,99,i+99,LCD_color(i,0,i));
	LCD_hline(100,119,i+99,LCD_color(i,i,0));
	LCD_hline(120,131,i+99,LCD_color(i,i,i));
}


while(1){
}
}
